/*
 * step.h
 *
 *  Created on: Apr 20, 2021
 *      Author: soliber
 */

#ifndef INC_STEP_H_
#define INC_STEP_H_

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* Macro Defines -------------------------------------------------------------*/
//configurable
#define MOTOR_PPR				(20*16)
#define MOTOR_PITCH				3000.0
#define MOTOR_POS_UM_MIN		0.0
#define MOTOR_POS_UM_MAX		55000.0
#define MOTOR_PULSE_FREQ_MAX	100000
//calculated
#define MOTOR_UM_PER_STEP		(MOTOR_PITCH/MOTOR_PPR)
#define MOTOR_STEP_MIN			(MOTOR_POS_UM_MIN/MOTOR_UM_PER_STEP)
#define MOTOR_STEP_MAX			(MOTOR_POS_UM_MAX/MOTOR_UM_PER_STEP)
//speed
#define MOTOR_SPEED_MAX			(MOTOR_UM_PER_STEP*10000)

/* Prototypes ----------------------------------------------------------------*/

int Motor_Init(void);
//origin
void Motor_Set_Origin(void);
//speed
int Motor_Get_Speed(void);
int Motor_Set_Speed(int speed_um_s);
//increment move
int Motor_Move_step(int dx_steps);
int Motor_Move_um(int dx_um);
//position move
int Motor_Get_Pos_step(void);
int Motor_Get_Pos_um(void);
int Motor_Pos_step(int x_steps);
int Motor_Pos_um(int x_um);

#endif /* INC_STEP_H_ */
